package com.kingdee.eas.cp.bc.baseData;

import com.kingdee.bos.BOSException;
import com.kingdee.bos.dao.ormapping.ObjectUuidPK;
import com.kingdee.bos.eventbus.event.action.KDActionEvent;
import com.kingdee.bos.webframework.exception.WafException;
import com.kingdee.bos.webframework.json.JSONUtils;
import com.kingdee.bos.webframework.dynamic.handler.AbstractWebEventHandler;
import com.kingdee.bos.eventbus.event.action.IActionEventHandler;
import com.kingdee.eas.common.EASBizException;
import com.kingdee.eas.custom.basedata.EvectionSubsiCollection;
import com.kingdee.eas.custom.basedata.EvectionSubsiFactory;
import com.kingdee.eas.custom.basedata.EvectionSubsiInfo;
import com.kingdee.eas.custom.basedata.MeetingCostFactory;
import com.kingdee.eas.custom.basedata.MeetingCostInfo;
import com.kingdee.eas.custom.basedata.inlandForeign;
import com.kingdee.eas.custom.basedata.timeIimit;

public class EvectionSubsiHandler extends AbstractWebEventHandler implements IActionEventHandler {
	public void onAction(KDActionEvent event) throws WafException,BOSException {
		String id=event.getReqeustContext().getHttpServletRequest().getParameter("id");
		String inlandForeignValue=event.getReqeustContext().getHttpServletRequest().getParameter("inlandForeignValue");
		String day=event.getReqeustContext().getHttpServletRequest().getParameter("day");
		String jobNameValue=event.getReqeustContext().getHttpServletRequest().getParameter("jobNameValue");
		EvectionSubsiInfo info = new EvectionSubsiInfo();
		try {
			info = EvectionSubsiFactory.getRemoteInstance().getEvectionSubsiInfo(new ObjectUuidPK(id));
			if(null!=inlandForeignValue&&null!=day){
				int dayNum=Integer.valueOf(day);
				String isTimeIimit="";
				if(dayNum<=30){
					isTimeIimit = timeIimit.FTRUE_VALUE;
				}else if(dayNum>30&&dayNum<90){
					isTimeIimit = timeIimit.A_VALUE;
				}else{
					isTimeIimit = timeIimit.B_VALUE;
				}
				if(!info.getInlandForeign().getValue().equals(inlandForeignValue)){
					JSONUtils.SUCCESS(null);
					return;
				}
				
				if(info.getInlandForeign()==inlandForeign.foreign&&!info.getTimeIimit().getValue().equals(isTimeIimit)){
					JSONUtils.SUCCESS(null);
					return;
				}
				
				if(info.getInlandForeign()==inlandForeign.foreign&&info.getTimeIimit()!=timeIimit.ftrue&&!info.getDutyTitle().getValue().equals(jobNameValue)){
					JSONUtils.SUCCESS(null);
					return;
				}
				
			}
		} catch (EASBizException e) {
			e.printStackTrace();
		}
		JSONUtils.SUCCESS(info);
	}
}